<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>from</title>
	<link rel="stylesheet" href="./layui/css/layui.css">
	<script type="text/javascript" src="./layui/layui.js"></script>
</head>
<body>
	<form class="layui-form" action="">
		用户名： <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
		<!-- lay-verify="required"  规定必填框 -->
		<input name="title" autocomplete="off" placeholder="请输入标题" class="layui-input" type="text">
		<button class="layui-btn" lay-submit="" lay-filter="reg">注册按钮</button>
	</form>	
	<script type="text/javascript">

		//要用那个模块要先声明模块
		layui.use(['form',], function(){
			var form = layui.form();
		layedit = layui.layedit
  		laydate = layui.laydate;
		 
		  // //自定义验证规则
		  // form.verify({
		  //   title: function(value){
		  //     if(value.length < 5){
		  //       return '标题至少得5个字符啊';
		  //     }
		  //   }	

		//监听提交
		  form.on('submit(reg)', function(data){
		    layer.alert(JSON.stringify(data.field), {
		      title: '最终的提交信息'
		    })
		    return false;
		  });
		  });
		});
	</script>
</body>
</html>